package lanqiao;

import java.util.Scanner;

public class test2_1 {
    //203
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length()!=str2.length()){
            System.out.println("NO");
            System.exit(0);
        }
        char[] chars1 = str1.toCharArray();
        char[] chars2 = str2.toCharArray();
        int i=0;
            for (int j = 0; j < chars2.length; ) {

                if (chars1[i]==chars2[j]) {
                            i++;
                            j=0;
                }
                else {
                    j++;
                }
                if(j==chars2.length){
                    System.out.println("NO");
                    System.exit(0);
                }
                if(i==chars1.length){
                    break;
                }
            }
            System.out.println("YES");
    }
}
